package com.rdxer.service;

import com.rdxer.core.utils.IdWorker;
import com.rdxer.model.Clazz;
import com.rdxer.model.ClazzStudentRelation;
import com.rdxer.model.Major;
import com.rdxer.repository.ClazzRepository;
import com.rdxer.repository.ClazzStudentRelationRepository;
import com.rdxer.repository.MajorRepository;
import lombok.Data;
import lombok.Getter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Department 服务层
 */
@Service
@Data
@Getter
public class ClazzService implements CRUDPageServiceInterface<Clazz, String>  {


    @Autowired
    private ClazzRepository repository;
    @Autowired
    private ClazzStudentRelationRepository relationRepository;
    @Autowired
    private IdWorker idWorker;

    public Clazz findByUserId(String userId) {
        List<ClazzStudentRelation> allByUserId = relationRepository.findAllByUserId(userId);
        String clazzId = allByUserId.get(0).getClazzId();
        return findById(clazzId);
    }
}
